home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / sbin / update-info-dir < prev    next >
Encoding:
Text File  |  2010-10-14  |  1.3 KB  |  65 lines

  1. #!/bin/bash
  2. # update-info-dir
  3. # create a dir file from all installed info files
  4. # Copyright 2009 Norbert Preining
  5. # GPLv2
  6.  
  7. INFODIR=/usr/share/info
  8.  
  9. set -e
  10.  
  11. #
  12. # since user's environment is taken over into root account when sudo-ing
  13. # we don't want that one's user LANGUAGE setting changes the messages in
  14. # the dir file. Unset LANGUAGE and reload /etc/environment to get
  15. # the system wide settings. See bug #536476
  16. unset LANGUAGE
  17. if [ -r /etc/environment ] ; then
  18.   . /etc/environment
  19. fi
  20. if [ -r /etc/default/locale ] ; then
  21.   . /etc/default/locale
  22. fi
  23.  
  24. if [ -n "$1" ] ; then
  25.   INFODIR="$1"
  26. fi
  27.  
  28. if [ ! -d "$INFODIR" ] ; then
  29.   echo "Not a directory: $INFODIR." >&2
  30.   exit 1
  31. fi
  32.  
  33. if [ -r "$INFODIR/dir" ] ; then
  34.   rm -f "$INFODIR/dir.old"
  35.   cp $INFODIR/dir $INFODIR/dir.old
  36. fi
  37.  
  38. # we have to remove the dir file not make ginstall-info being surprised
  39. rm -f "$INFODIR/dir"
  40.  
  41. errors=0
  42. find "$INFODIR" -type f | while read file ; do
  43.   case $file in
  44.     */dir|*/dir.gz|*/dir.old|*/dir.old.gz|*-[0-9]|*-[0-9].gz|*-[1-9][0-9]|*-[1-9][0-9].gz|*.png)
  45.       # these files are ignored
  46.       continue
  47.       ;;
  48.     *)
  49.       ginstall-info "$file" "$INFODIR/dir" || {
  50.         errors=$[errors+1]
  51.       }
  52.       ;;
  53.   esac
  54. done
  55.  
  56. if [ $errors -gt 0 ] ; then
  57.   exec >&2
  58.   echo
  59.   echo "Updating the index of info documentation produced $errors errors."
  60. fi
  61.  
  62. exit 0
  63.  
  64. # vim:set expandtab tabstop=2: #
  65.